import java.awt.event.MouseEvent;

public class Extern implements IPlayer
{
	private boolean played;
	private Grid grid;

	public Extern(Grid g)
	{
		grid = g;
	}

	public int play()
	{	
		Int pos = new Int(0);
		
		Fichier.save("buffer.tmp", grid);

		boolean ok = false;
		played = false;
		do
		{
			do
			{
				try
				{	
					Thread.currentThread();
					Thread.sleep(200);
				}
				catch(InterruptedException ie){}
			}
			while(played == false);
			
			Fichier.load("buffer.tmp", grid, pos);

			if(pos.getVal() == -1)
			{
				played = false;
				System.out.println("Attendez que le Client Externe joue !");
			}
			else
				ok = true;
		}
		while(ok == false);
		
		return pos.getVal();
	}

	public void mouseClicked(MouseEvent e) {}
	public void mouseEntered(MouseEvent e) {}
	public void mouseExited(MouseEvent e) {}
	public void mousePressed(MouseEvent e) {}
	public void mouseReleased(MouseEvent e)
	{
		played = true;
	}
}